﻿package CutLoad.components
{
	/**
	 * 组件皮肤配置文件,与lib.swf一起使用 
	 * @author smallerbird
	 * 
	 */	
	public class Skin
	{
		private static var isInstance:Boolean=false;
		private static var _instance:Skin;
		//用于保存一组皮肤
		private var arr:Array
		//获认皮肤
		private var SkinType:uint=0
		public function Skin()
		{
			if(isInstance){
				throw new Error("只能实例一次");
			}else{
				isInstance=true;
				_instance=this;
				iniSkinGroup();
			}
		}
		/**
		 * 获得一个实例 
		 * @return 
		 * 
		 */		
		public static function getInstance():Skin{
			if(!isInstance){
				_instance=new Skin();
				isInstance=true;
			}
			return _instance;
		}
		/**
		 * 设置默认主题
		 * @param SkinType
		 * 
		 */		
		public function setSkinType(SkinType:uint):void{
			if(SkinType>arr.length-1){
				throw new Error("不存在的皮肤主题，目前只有:"+arr.length);
			}
			this.SkinType=SkinType
		}
		/**
		 * 获得皮肤
		 * @param index
		 * @return 
		 * 
		 */		
		public function getSkin(index:Number=0):Array{
			if(index>arr[SkinType].length-1){
				throw new Error("不存在的皮肤");
			}
			var arrClassName:Array=arr[SkinType][index];
			return arrClassName;
		}
		//设置皮肤组
		private function iniSkinGroup():void{
			arr=new Array();
			var myButton:Array;
			var myFrame:Array;
			var myScoll:Array;
			var myComboBox:Array;
			var myTip:Array;
			var myWait:Array;
			var myCheckBox:Array;
			var myRadioButton:Array;
			var myTabbed:Array;
			var myTree:Array;
			var myColorPicker:Array;
			//这里添加皮肤----------------------------------------------------------------------
			//样式1----------------------------------------start
			var arrTem:Array=new Array();
			//0按钮参数说明：[up,over,down,disabled,状态1按钮字体色，状态1字尺寸,状态2按钮字体色，状态2字尺寸,微调方本的x,微调方本的y,文本与背景的左右边距x,文本与背景的上下边距y]
			myButton=["Button_defaultImage","Button_rolloverImage","Button_pressedImage","Button_disabledImage",0x000000,12,0xFF0000,12,0,-2,10,2];
			arrTem.push(myButton)
			/*1
				窗口参数说明：
					[
						[背景]，
						[最小化按钮....]，
						[最大化按钮....]，
						[还原的按钮....]，
						[关闭按钮......],
						[容器放置的信息.],
						[标题文字颜色,字大小]
					]
				*/
			myFrame=[
				["Frame_activeBG"],
				["Frame_iconifiedIcon_defaultImage","Frame_iconifiedIcon_rolloverImage","Frame_iconifiedIcon_rolloverImage","Frame_iconifiedIcon_disabledImage"],
				["Frame_maximizeIcon_defaultImage","Frame_maximizeIcon_rolloverImage","Frame_maximizeIcon_pressedImage","Frame_maximizeIcon_disabledImage"],
				["Frame_normalIcon_defaultImage","Frame_normalIcon_rolloverImage","Frame_normalIcon_pressedImage","Frame_normalIcon_disabledImage"],
				["Frame_closeIcon_defaultImage","Frame_closeIcon_rolloverImage","Frame_closeIcon_pressedImage","Frame_closeIcon_disabledImage"],
				[new RectRule(4,24,4,4)],
				[0xff0000,13]
			];
			arrTem.push(myFrame);
			
			/*2
			      滚动条容器，参数说明
			  [
				[背景],
				[向上按钮的四个状态].
				[拖动条的四个状态]，
				[向下按钮的四个状态]
			   ]
			
			  */
			myScoll=[
				["ScrollBar_verticalBGImage"],
				["ScrollBar_arrowUp_defaultImage","ScrollBar_arrowUp_rolloverImage","ScrollBar_arrowUp_pressedImage","ScrollBar_arrowUp_disabledImage"],
				["ScrollBar_thumbVertical_defaultImage","ScrollBar_thumbVertical_rolloverImage","ScrollBar_thumbVertical_iconImage"],
				["ScrollBar_arrowDown_defaultImage","ScrollBar_arrowDown_rolloverImage","ScrollBar_arrowDown_pressedImage","ScrollBar_arrowDown_disabledImage"]
			];
			arrTem.push(myScoll);
			/*3
			下拉列表框，参数说明
			[
			[下拉按钮的四个状态],
			[左边那个箭头的宽度]
			]
			*/
			myComboBox=[
				["ComboBox_defaultImage","ComboBox_defaultRolloverImage","ComboBox_defaultPressedImage","ComboBox_disabledImage"],
				[17]
			];
			arrTem.push(myComboBox);
			
			/*4
			提标框边框背景
			["背景框",内容距离边框的距离x,内容距离边框的距离y,背景框的左右宽度（主要是给背景提供一个参考）,背景框的上下宽度（主要是给背景提供一个参考）]
			*/			
			myTip=["TipBorder",10,10,4,4];
			arrTem.push(myTip);
			
			arr.push(arrTem);
			/*5
			等待窗口，加载的动画条
			["库名",宽，高,窗口宽，窗口高]
			*/
			myWait=["waitPadLoadIco",35,35,200,80];
			arrTem.push(myWait);
			/*6
			多项框
			[[未选重前的四个状态]，
			[选重前的四个状态]]
			*/
			myCheckBox=[["CheckBox_defaultImage","CheckBox_rolloverImage","CheckBox_pressedImage","CheckBox_disabledImage"],
			["CheckBox_selectedImage","CheckBox_rolloverSelectedImage","CheckBox_pressedSelectedImage","CheckBox_disabledSelectedImage"]];
			arrTem.push(myCheckBox);
			/*
			7
			单选按钮
			[[未选重前的四个状态]，
			[选重前的四个状态]]
			*/
			myRadioButton=[["RadioButton_defaultImage","RadioButton_rolloverImage","RadioButton_pressedImage","RadioButton_disabledImage"],
				["RadioButton_selectedImage","RadioButton_rolloverSelectedImage","RadioButton_pressedSelectedImage","RadioButton_disabledSelectedImage"]];
			arrTem.push(myRadioButton);
			
			/*
			8
			分页窗口
			[
			不是当前分页按钮状态1或是当前分页按钮状态2，
			不是当前分页按钮状态2或是当前分页按钮状态1，
			分页标题按钮状态3，
			分页标题按钮状态4，
			分页的边框,
			边框y坐标微调参数：当前分页的按钮要盖住边框线，
			]
			*/
			myTabbed=["TabbedPane_top_tab_defaultImage","TabbedPane_top_tab_rolloverImage","TabbedPane_top_tab_pressedImage","TabbedPane_top_tab_disabledImage",
				"TabbedBorder"
				,3]
			arrTem.push(myTabbed);
			/*
			9
			二级树菜单
			*/
			myTree=["Tree_folderExpandedImage","Tree_leafImage"];
			arrTem.push(myTree);
			/*
			10
			拾色器
			[按钮的4种状态]
			*/
			myColorPicker=["ColorPicker_upSkin","ColorPicker_overSkin","ColorPicker_downSkin","ColorPicker_disabledSkin"]
			arrTem.push(myColorPicker);
			//
			arr.push(arrTem);
			//样式1---------------------------------------------end
		}
	}
}